package com.capricornus.demo.common;

import io.swagger.annotations.ApiModelProperty;

/**
 * @author ：jxgahxs
 * @version ：2020/12/31
 */
public class ResponseResult<T> {

    private Boolean result = true;

    private Integer code = 200;

    private String msg = "";

    private T data = null;

    public Boolean getResult() {
        return result;
    }

    public void setResult(Boolean result) {
        this.result = result;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public ResponseResult(Boolean result, Integer code, String msg, T data) {
        this.result = result;
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static <T> ResponseResult<T> ok() {

        return new ResponseResult(true, 200, "OK", (Object)null);
    }

    public static <T> ResponseResult<T> ok(String msg) {

        return new ResponseResult(true, 200, msg, (Object)null);
    }

    public static <T> ResponseResult<T> ok(T data) {

        return new ResponseResult(true, 200, "OK", data);
    }

    public static <T> ResponseResult<T> error(String msg) {

        return new ResponseResult(false, 500, msg, (Object)null);
    }

}
